﻿Imports System.Configuration
Imports System.Data.SqlClient
Public Class DataProvider
    Private Shared _con As SqlConnection = Nothing
    Shared Sub New()
        Dim strConnection = ConfigurationManager.ConnectionStrings("cnnStr").ConnectionString
        _con = New SqlConnection(strConnection)
    End Sub
    Public Function ExecuteQuery(ByVal strQuery As String) As DataTable

        Dim resTable As New DataTable()
        Try
            _con.Open()
            Dim adapter As New SqlDataAdapter(strQuery, _con)
            adapter.Fill(resTable)
        Catch ex As Exception
            Throw New Exception("loi thuc thi sql :" + ex.Message.ToString())
        Finally
            _con.Close()
        End Try


        Return resTable
    End Function
End Class
